package com.jinxin.platform.cdelecinspect.rpc;

import com.alibaba.fastjson.JSON;
import com.jinxin.platform.base.common.pojo.InvokeCfg;
import com.jinxin.platform.base.common.pojo.JsonResult;
import com.jinxin.platform.base.common.support.BusinessDelegate;
import com.jinxin.platform.cdelecinspect.domain.SysUserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @description: (描述...)
 * @return:
 * @author: Lingnan
 * @time: 2020/08/12 15:37
 */
@Component
public class SysUserRpc {

    @Autowired
    private BusinessDelegate businessDelegate;

    /**
     * 获取当前用户对象
     *
     * @return SysUser
     */
    public SysUserVO getCurrentUser() {
        InvokeCfg cfg = new InvokeCfg();
        cfg.setModuleKey("eleinspectProjectUser");
        cfg.setClassName("EleinspectUserRpcService");
        cfg.setFunName("getEleinspectCurrentUser");
        JsonResult result = businessDelegate.invoke(cfg);
        if (result.getSuccess()) {
            if (result.getData() == null) {
                return null;
            }
            return JSON.parseObject(JSON.toJSONString(result.getData()), SysUserVO.class);
        }
        else {
            SysUserVO userVO = new SysUserVO();
            userVO.setUserId("1");
            userVO.setUserAccount("admin");
            userVO.setUserName("王麻子");
            return userVO;
        }
//        return null;
    }


}
